package com.stone.databinding.ui;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProviders;

import android.os.Bundle;
import com.stone.databinding.R;
import com.stone.databinding.data.ProfileLiveDataViewModel;
import com.stone.databinding.data.ProfileObservableViewModel;
import com.stone.databinding.databinding.ActivityViewModelBinding;

public class ViewModelActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //ProfileLiveDataViewModel viewModel = ViewModelProviders.of(this).get(ProfileLiveDataViewModel.class);
        // An alternative ViewModel using Observable fields and @Bindable properties can be used:
        ProfileObservableViewModel viewModel = ViewModelProviders.of(this).get(ProfileObservableViewModel.class);

        ActivityViewModelBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_view_model);
        binding.setViewmodel(viewModel);
        binding.setLifecycleOwner(this);
    }
}
